package cn.edu.neusoft.demo.hospital2.Service.impl;

import cn.edu.neusoft.demo.hospital2.Service.EmailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.mail.SimpleMailMessage;
import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.stereotype.Service;

@Service
public class EmailServiceImpl implements EmailService {

    @Autowired
    private JavaMailSender mailSender;

    // 可以从配置文件中读取
    private final String fromEmail = "molu_0730@qq.com"; // 改成你的测试邮箱
    private final String fromName = "医院反馈系统";

    @Override
    public void sendFeedbackEmail(String toEmail, String content) {
        SimpleMailMessage message = new SimpleMailMessage();
        message.setFrom(fromName + " <" + fromEmail + ">"); // 设置发件人名称和邮箱
        message.setTo(toEmail);
        message.setSubject("【医院系统】您的反馈已收到");
        message.setText("尊敬的用户：\n\n" +
                "感谢您使用我们的反馈系统！\n\n" +
                "您的反馈内容如下：\n" + content +
                "\n\n我们会尽快处理您的反馈。\n\n" +
                "此致\n敬礼\n\n医院管理系统团队");

        mailSender.send(message);
    }
}